//SPDX-License-Identifier: UNLICENSED pragma solidity >=0.6; // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md // ---------------------------------------------------------------------------- interface ERC20Interface { function totalSupply() external view returns (uint); function balanceOf(address tokenOwner) external view returns (uint balance); function transfer(address to, uint tokens) external returns (bool success); function allowance(address tokenOwner, address spender) external view returns (uint remaining); function approve(address spender, uint tokens) external returns (bool success); function transferFrom(address from, address to, uint tokens) external returns (bool success); event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } contract ColettiMoney is ERC20Interface{ string public name ="Coletti"; string public symbol = "CLT"; uint public decimals=0; uint public supply; address public founder; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // example: allowed[0xdfdds][0x45555]=20 constructor(uint s) { supply=s; founder=msg.sender; balances[founder]=supply; } function totalSupply() public view override returns (uint){ return(supply); } function balanceOf(address tokenOwner) public view override returns (uint){ return(balances[tokenOwner]); } function transfer(address to, uint tokens) public override returns (bool){ require(tokens>0 && balances[msg.sender]>=tokens); balances[msg.sender]=balances[msg.sender]-tokens; balances[to]=balances[to]+tokens; emit Transfer(msg.sender,to,tokens); return(true); } function allowance(address tokenOwner, address spender) public view override returns (uint){ return(allowed[tokenOwner][spender]); } function approve(address spender, uint tokens) public override returns (bool){ require(balances[msg.sender]>=tokens); allowed[msg.sender][spender]=tokens; emit Approval(msg.sender,spender,tokens); return(true); } function transferFrom(address from, address to, uint tokens) public override returns(bool){ require(tokens>0 && balances[from]>=tokens && allowed[from][msg.sender]>=tokens); balances[from]=balances[from]-tokens; allowed[from][msg.sender]=allowed[from][msg.sender]-tokens; balances[to]=balances[to]+tokens; emit Transfer(from, to, tokens); return(true); } }